package com.mccree.order.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * swagger配置
 * @Author: MccRee
 * @Date: 2022/6/1 10:38
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean(value = "defaultApi")
    public Docket defaultApi(Environment environment){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .description("订单模块接口文档")
                        .termsOfServiceUrl("http://www.bingo.com/")
                        .version("1.0")
                        .build()
                ).groupName("订单模块后台")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.mccree.order.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
